package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.system.SysTaocan;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.service.ISysTaocanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/system/taocan")
public class SysTaocanController extends BaseController {
    @Autowired
    private ISysTaocanService sysTaocanService;

    /**
     * 查询包船套餐列表
     */
//    @PreAuthorize("@ss.hasPermi('system:taocan:list')")
    @GetMapping("/list")
    public AjaxResult list(SysTaocan sysTaocan) {
        List<SysTaocan> result = sysTaocanService.selectSysTaocanList(sysTaocan);
        return success(result);
    }

    /**
     * 获取包船套餐详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:taocan:query')")
    @GetMapping(value = "/{taocanId}")
    public AjaxResult getInfo(@PathVariable("taocanId") Long taocanId) {
        return success(sysTaocanService.selectSysTaocanByTaocanId(taocanId));
    }

    /**
     * 新增包船套餐
     */
//    @PreAuthorize("@ss.hasPermi('system:taocan:add')")
    @Log(title = "包船套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTaocan sysTaocan) {
        sysTaocan.setCreateBy(getUsername());
        sysTaocan.setCreateTime(DateUtils.getNowDate());
        return toAjax(sysTaocanService.insertSysTaocan(sysTaocan));
    }

    /**
     * 修改包船套餐
     */
//    @PreAuthorize("@ss.hasPermi('system:taocan:edit')")
    @Log(title = "包船套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTaocan sysTaocan) {
        sysTaocan.setUpdateBy(getUsername());
        sysTaocan.setUpdateTime(DateUtils.getNowDate());
        return toAjax(sysTaocanService.updateSysTaocan(sysTaocan));
    }

    /**
     * 删除包船套餐
     */
//    @PreAuthorize("@ss.hasPermi('system:taocan:remove')")
    @Log(title = "包船套餐", businessType = BusinessType.DELETE)
    @DeleteMapping("/{taocanIds}")
    public AjaxResult remove(@PathVariable Long[] taocanIds) {
        return toAjax(sysTaocanService.deleteSysTaocanByTaocanIds(taocanIds));
    }
}
